﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Djs.WinForm.Components;
using System.Drawing;
using System.Drawing.Imaging;

namespace Djs.Games.DeskGame.GameComponents
{
    public class RandomPanel : DblPanel
    {
        protected override void OnPaintToBuffer(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaintToBuffer(sender, e);

        }

        /// <summary>
        /// Knihovna obrázků. Může být sdílená s jinými objekty.
        /// Je autoinicializační (nikdy není null).
        /// </summary>
        public GameImageLibrary ImageLibrary
        {
            get
            {
                if (this._ImageLibrary == null)
                    this._ImageLibrary = new GameImageLibrary();
                return this._ImageLibrary;
            }
            set { this._ImageLibrary = value; }
        }
        private GameImageLibrary _ImageLibrary;

    }
    public class ImageEdit
    {
        public static Image Recolor(Image image)
        {
            Bitmap bm = image.Clone() as Bitmap;

            int y = bm.Size.Height / 2;
            for (int x = 0; x < bm.Size.Width; x++)
                bm.SetPixel(x, y, Color.DarkRed);

            return bm.Clone() as Image;
        }
        public static Image Recolor(Image image, int c)
        {
            Bitmap bm = image.Clone() as Bitmap;

            float[][] colorMatrixElements = {
                new float[] {2,  0,  0,  0, 0},        // red scaling factor of 2
                new float[] {0,  1,  0,  0, 0},        // green scaling factor of 1
                new float[] {0,  0,  1,  0, 0},        // blue scaling factor of 1
                new float[] {0,  0,  0,  1, 0},        // alpha scaling factor of 1
                new float[] {.2f, .2f, .2f, 0, 1}};    // three translations of 0.2

            ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);

            ImageAttributes imageAttributes = new ImageAttributes();
            imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);


            int width = image.Width;
            int height = image.Height;

            int y = bm.Size.Height / 2;
            for (int x = 0; x < bm.Size.Width; x++)
                bm.SetPixel(x, y, Color.DarkRed);

            return bm.Clone() as Image;
        }

    }
}
